package com.kongxx.wicketstudy.validating;

import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.validation.validator.NumberValidator;

public class ValidatePage extends WebPage {

	private static final long serialVersionUID = 1L;
	private Request request = new Request(0, "");

	public ValidatePage() {
		add(new FeedbackPanel("feedback"));
		Form form = new Form("myform", new CompoundPropertyModel(request)) {
			protected void onSubmit() {

			}
		};
		TextField weight = new TextField("weight", Integer.class);
		weight.setRequired(true);
		weight.add(NumberValidator.minimum(0));
		form.add(weight);

		TextField patronCode = new TextField("patronCode");
		patronCode.add(new PatronCodeValidator());
		form.add(patronCode);

		add(form);
	}
}
